package com.example.appframework.chatroom.chatmain;

import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.appframework.R;
import com.tencent.qcloud.tim.uikit.modules.chat.ChatLayout;
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo;

public class ChatMainFragment extends Fragment {

    private ChatMainViewModel mViewModel;

    public static ChatMainFragment newInstance() {
        return new ChatMainFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.chat_main_fragment, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewModel = ViewModelProviders.of(this).get(ChatMainViewModel.class);
        // TODO: Use the ViewModel

        ChatLayout chatLayout = getView().findViewById(R.id.chat_layout);
        // 单聊面板的默认 UI 和交互初始化
        chatLayout.initDefault();
// 传入 ChatInfo 的实例，这个实例必须包含必要的聊天信息，一般从调用方传入
// 构造 mChatInfo 可参考 StartC2CChatActivity.java 的方法 startConversation
        ChatInfo mChatInfo = new ChatInfo();
        chatLayout.setChatInfo(mChatInfo);
    }

}